<?php
    $formulario = mktime(date("his"));
    $id_vent = "vent_".$formulario;
    $this->Vista->ventana(DLOAD,DVENTANA,'BUSQUEDA FILTRADA','Sigesp/control_asistencias_busqueda_filtro',$formulario,'buscar',0,'820','550',$id_vent);
?>
<div id="<?php echo DVENTANA;?>_2" style="display:none;" class="x-hide-display">
<?php
    echo $this->Interfaz->formulario($formulario);
    echo $this->Interfaz->filset('Configuracion',1);
    echo $this->Interfaz->inputoculto('vent_filtro', $id_vent);
?>

<table id="tabla" border='0' cellpadding='0' cellspacing='0' width='98%' align='center' style="border:5;">
    <tr>
        <td align="center">Ip Servidor:&nbsp;&nbsp;<?php $validar = "this.value=this.value.replace(/[^0-9.]/, '')";
        echo $this->Interfaz->input('ip_servidor', 15, 'todo', 'inputn', 7, 15, $filtro['Biometrico']['ip_servidor'], 0, 1, 'Ip del Servidor', '111.222.333.444', array('id'=>'ip_servidor', 'OnKeyUp'=>$validar)); ?></td>
    </tr>
</table>
<?php echo $this->Interfaz->filset();?>

<?php echo $this->Interfaz->filset('Filtros de la Busqueda',1); ?>
<table id="tabla" border='0' cellpadding='15' cellspacing='15' width='100%' align='center' style="border:5; padding: 5px;">
    <tr>
        <td>Fecha Inicio: </td>
        <td><?php
            echo $this->Interfaz->input('f_inicio', 12, 'fecha', 'inputn', 0, 11, $filtro['Biometrico']['f_inicio'], 0, 1, 'Fecha de Inicio a Considerar');
            $des = date('d-m-') . (date('Y') - 5);
            $has = date('d-m-') . (date('Y') + 5);
            echo $this->Interfaz->calendario('f_inicio', null, $des, $has); ?></td>
        <td rowspan="4">Dias a considerar</td>
        <td rowspan="4"><?php $sem = array(1 => 'Lunes', 2 => 'Martes', 3 => 'Miercoles', 4 => 'Jueves', 5 => 'Viernes', 6 => 'Sabados', 0 => 'Domingo');
                $default = explode(',', $filtro['Biometrico']['semana']);
                $otros = array('id'=>'semana','style'=>'height: 140px', 'class'=>'selectcolors', 'multiple'=>'multiple', 'default'=> $default);
                echo $this->Form->select('semana', $sem, $otros); ?>
        </td>
    </tr>
    <tr>
        <td>Fecha Fin: </td>
        <td><?php
            echo $this->Interfaz->input('f_fin', 12, 'fecha', 'inputn', 0, 11, $filtro['Biometrico']['f_fin'], 0, 1, 'Fecha de Fin a Considerar');
            $des = date('d-m-') . (date('Y') - 5);
            $has = date('d-m-') . (date('Y') + 5);
            echo $this->Interfaz->calendario('f_fin', null, $des, $has); ?></td>
    </tr>
    <tr>
        <td>Hora Entrada: </td>
        <td><?php echo $this->Interfaz->input('h_entrada', 10, 'hora', 'inputn', 0, 8, $filtro['Biometrico']['h_entrada'], 0, 1, 'Hora de Entrada', '07:40:00'); ?></td>
    </tr>
    <tr>
        <td>Hora Salida: </td>
        <td><?php echo $this->Interfaz->input('h_salida', 10, 'hora', 'inputn', 0, 8, $filtro['Biometrico']['h_salida'], 0, 1, 'Hora de Salida', '16:00:00'); ?></td>
    </tr>
    <tr>
        <td>Horas Extras: </td><td><?php echo $this->Interfaz->input('h_extra', 10, 'hora', 'inputn', 0, 8, $filtro['Biometrico']['h_extra'], 0, 1, 'Horas Extras','01:00:00'); ?></td>
        <td colspan='2'>Excepciones: <?php
            echo $this->Interfaz->input('excep', 12, 'fecha', 'inputn', 0, 11, '', 0, 0, 'Fecha a omitir en la busqueda');
            $des = date('d-m-') . (date('Y') - 5);
            $has = date('d-m-') . (date('Y') + 5);
            echo $this->Interfaz->calendario('excep', null, $des, $has);
            echo $this->Interfaz->img('iconos/icons/add.png', 'Agregar','Agregar', 15, 15, array('type' => 'button',
                'onClick' => "(function () {
                                var fecha = document.getElementById('excep').value;
                                var nolaboral = document.getElementById('NoLaboral').value;
                                var separador = ', ';

                                if (nolaboral=='')
                                    var separador = '';
                                 
                                if (fecha!='') {
                                    document.getElementById('NoLaboral').value = nolaboral + separador + fecha;
                                    document.getElementById('excep').value = '';
                                }
                    }());"));
            ?>
        </td>
    </tr>
    <tr>
        <td>Cedula: </td><td><?php echo $this->Interfaz->input('cedula', 10, 'numerico', 'inputn', 5, 9, ($filtro['Biometrico']['cedula']==0 ? null : $filtro['Biometrico']['cedula']), 0, 0, 'Cedula del personal', '12345678', null, array('id'=>'ip_servidor', 'OnKeyUp'=>$validar)); ?></td>
        <td colspan="2"><?php $otros=array('id'=>'NoLaboral','rows'=>'1', 'cols'=>'25', 'style'=>'resize: none');
            echo $this->Interfaz->input('NoLaboral', 12, 'textarea', 'inputn', 0, 10, ($filtro['Biometrico']['no_laboral']==0 ? null : $filtro['Biometrico']['no_laboral']), 1, 0, 'Fecha de la semana a Considerar', null, $otros);?>
        <?php
            echo $this->Interfaz->img('iconos/icons/borrar.png', 'Vaciar','Vaciar', 15, 15, array('type' => 'button',
                'onClick' => "(function () {
                                document.getElementById('NoLaboral').value = '';
                    }());"));
        ?>
        </td>
    </tr>
    <tr>
        <td>Criterios: </td>
        <td><?php $lista=array('A' => 'A - RETARDO ENTRADA', 'B' => 'B - SALIDA TEMPRANA', 'C' => 'C - FILTROS A Y B', 'D' => 'D - SOBRETIEMPO', 'E' => 'E - TODOS');
                $d_crit =  array($filtro['Biometrico']['criterios']);
                echo $this->Form->select('criterios', $lista, array('id'=>'criterios', 'default'=> $d_crit)); ?></td>
        <td colspan="2">Personal a omitir: <?php echo $this->Interfaz->input('p_omitir', 5, 'numerico', 'inputn', 3, 5, '', 0, 0, 'Id del personal a omitir en la busqueda');
            echo $this->Interfaz->img('iconos/icons/add.png', 'Agregar','Agregar', 15, 15, array('type' => 'button',
                        'onClick' => "(function () {
                                    var p_omitir = document.getElementById('p_omitir').value;
                                    var omitir = document.getElementById('omitir').value;
                                    var separador = ',';

                                    if (omitir=='')
                                        var separador = '';

                                    if (p_omitir.length >= 1 ) {
                                        document.getElementById('omitir').value = omitir + separador + p_omitir;
                                        document.getElementById('p_omitir').value = '';
                                    }
                        }());"));
            echo $this->Interfaz->img('iconos/icons/delete.gif', 'Eliminar','Eliminar', 15, 15, array('type' => 'button',
                        'onClick' => "(function () {
                                    var p_omitir = document.getElementById('p_omitir').value;
                                    var omitir = document.getElementById('omitir').value;

                                    if (p_omitir.length >= 1) {
                                        var reemplazo = omitir.split(',');
                                            for (var i = 0; i < reemplazo.length; i++){
                                                reemplazo[i] = reemplazo[i].replace(/^\s+/g,'').replace(/\s+$/g,'');
                                                if (reemplazo[i] == p_omitir){
                                                    reemplazo[i] = '';
                                                    reemplazo.splice(i,1);
                                                }
                                            }
                                        document.getElementById('omitir').value = reemplazo;
                                        document.getElementById('p_omitir').value = '';
                                    }
                        }());"));?></td>
    </tr>
    <tr>
        <td colspan="4" align="center"><?php $otros = array('id'=>'omitir','rows'=>'1', 'cols'=>'70', 'style'=>'resize: none');
            echo $this->Interfaz->input('omitir', 12, 'textarea', 'inputn', 0, 5, ($filtro['Biometrico']['ids_omitir']==0 ? null : $filtro['Biometrico']['ids_omitir']), 1, 0, 'Id del personal a omitir', null, $otros);?>
        <?php
           echo $this->Interfaz->img('iconos/icons/borrar.png', 'Vaciar','Vaciar', 15, 15, array('type' => 'button',
                'onClick' => "(function () {
                                document.getElementById('omitir').value = '';
                    }());"));
        ?>
        </td>
    </tr>
    

</table>
<?php echo $this->Interfaz->filset();?>
</div>
<style>
   #tabla {
       border-collapse: separate;
       border-spacing: 5px;
   }
</style>
